home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-15 | 16.9 KB | 495 lines | [TEXT/MPS ] |
- //
- // daRules.r
- //
- // Includes : system version screening, as well as customized user interface
- // and installation contents, based on existing system version of selected
- // target volume.
- //
- // This example will install a Desk Accessory with the method proper to
- // the existing system folder on the selected target volume. Installation
- // of a Desk Accessory was chosen for this example because this is one of
- // the many cases where you may need to provide different installations
- // based upon which version of the operating system the user has.
- //
- // Your needs may differ from this example. Many developers produce
- // applications that are dependent on System 7, and will not run under
- // System 6. In those cases, simply add a package containing your software
- // if the proper system version is found on the selected target volume.
- //
- // If a proper system version cannot be found on the target volume
- // you may add the rule clause ReportVolError to dim or disable the Install
- // button in the dialog to prevent the user from installing software
- // that is inappropriate for the selected volume.
- //
- // In this example we have arbitrarily chosen System 6.0 as the minimum
- // system required for installation. Your Desk Accessory may have different
- // requirements.
- //
- // You may wish to allow the user to install software that falls outside
- // of the recommended installation. Use Custom Install for these cases.
- //
- // This example checks for system version by checking the file version
- // of the System file on the selected target volume. This is not necessarily
- // the version of the currently running operating system. Users may have
- // different versions of system folders on different hard disks. The system
- // version that will be checked is that of the blessed system folder
- // on the currently selected target volume.
- //
- // The CheckFileVersion call will look for an active system folder on
- // the selected target volume when checking the version of the System
- // file. The target spec used in the CheckFileVersion call uses the path
- // "special-macs:" which will look for an existing blessed system folder.
- // Once the blessed system folder has been found, target spec will 'point'
- // to the System file within the blessed system folder. If no blessed system
- // folder is found, path "special-macs:" will default to ":System Folder:".
- // In the case where the user has removed the Finder file from folder named
- // "System Folder" that still contains a copy of the System file, this check
- // for an existing system version on the target volume may be erroneous.
- //
- //
- // IMPORTANT: As of Installer version 4.0.3, the ReportVolError and
- // ReportSysError rule clauses do not function correctly when used
- // within the Global framework. Both rule clauses should disable the
- // Install button, and ReportSysError should disable the Switch Disk
- // button. Currently, when either of these rule clauses is evoked from
- // within the Global framework neither the Install or Switch Disk buttons
- // are disabled. Both rule clauses do work correctly within the Easy and
- // Custom frameworks. As a result, it is recommended that Report Error
- // clauses be implemented within Easy and Custom frameworks exclusively.
- //
- // mark young • 08/17/94
- //
- // Copyright 1993-1994, Apple Computer, Inc., All Rights Reserved
- //
-
- #include "InstallerTypes.r"
-
-
- // constants for packages, comments, comment text
- #define k70Package 200 // package for 7.0
- #define k60Package 300 // package for 6.0
-
- #define kCurrentReleaseDate 8151994 // dummy date ( just today's date )
- #define kCurrentVersion 403 // dummy version ( from installer vers )
-
- // target spec of system file for comparing system versions
- // as well as the target spec for 6.0 installs
- #define kSystemFileTarget 20000
-
- #define kKeyCaps70FileTarget 20001
-
- // source spec of Key Caps file ( for both 7.0 and 6.0 installs )
- #define kKeyCapsSourceSpec 20002
-
- #define kEasy70Rule 8070
- #define kEasy60Rule 8060
-
- #define kCustom70Rule 9070
- #define kCustom60Rule 9060
-
- #define kBadVersionRule 9999
-
-
- // • easy install setup
-
- // easy install framework uses ID other than 765 or 766
- // recommended to always use ID 764
- resource 'infr' (764) {
- format0 {{
- // execute first true rule
- pickFirst, { kEasy70Rule, kEasy60Rule, // check system version
- kBadVersionRule }, // if not supported give error
-
- }}
- };
-
- resource 'inrl' ( kEasy70Rule ) {
- format0 {{
- // check for 7.0 or greater
- CheckFileVersion{ kSystemFileTarget, // target file spec
- 7, // major revision
- 0, // minor revision
- release, // release stage
- 0 }, // incremental version
-
- // if 7.0 or greater add System 7 package
- AddPackages{{ k70Package }},
- AddUserDescription{ "Install KeyCaps Desk Accessory "
- "for use under System 7." },
- }}
- };
-
- resource 'inrl' ( kEasy60Rule ) {
- format0 {{
- // check for 6.0 or greater
- CheckFileVersion{ kSystemFileTarget, // target file spec
- 6, // major revision
- 0, // minor revision
- release, // release stage
- 0 }, // incremental version
-
- // if 6.0 or greater add System 6 package
- AddPackages{{ k60Package }},
- AddUserDescription{ "Install KeyCaps Desk Accessory "
- "for use under System 6." },
- }}
- };
-
-
- // • custom install setup
-
- // custom install framework always uses ID of 766
- resource 'infr' (766) {
- format0 {{
- // execute first true rule
- pickFirst, { kCustom70Rule, kCustom60Rule, // check system version,
- kBadVersionRule }, // if not supported give error
-
- }}
- };
-
- // rule that checks system version of target volume
- resource 'inrl' ( kCustom70Rule ) {
- format0 {{
- // this returns false unless system version is greater than 7.0
- CheckFileVersion{ kSystemFileTarget, // target file spec
- 7, // major revision
- 0, // minor revision
- release, // release stage
- 0 }, // incremental version
-
- AddCustomItems{{ k70Package }},
- }}
- };
-
- // rule that checks system version of target volume
- resource 'inrl' ( kCustom60Rule ) {
- format0 {{
- // this returns false unless system version is greater than 6.0
- CheckFileVersion{ kSystemFileTarget, // target file spec
- 6, // major revision
- 0, // minor revision
- release, // release stage
- 0 }, // incremental version
-
- AddCustomItems{{ k60Package }},
- }}
- };
-
- // • used in both easy and custom
-
- // generate an error symbol, disable INSTALL button, display an error message
- resource 'inrl' ( kBadVersionRule ) {
- format0 {{
- ReportVolError{ "System 6.0 or greater required for installation !!" }
- }}
- };
-
- // • packages
-
- // 7.0 or greater
- resource 'inpk' ( k70Package ) {
- format0 {
- showsOnCustom, // if this was a subpackage,
- // it would be listed in Custom Install
-
- removable, // include this package or subpackage
- // as a removeable item
-
- dontForceRestart, // don't make user reboot after installation
- k70Package, // 'inpc' resource ID ( item defined below )
- 0, // Package size ( if 0, filled in by ScriptCheck )
-
- "KeyCaps DA in Apple Menu", // Custom Install selection text
-
-
- { // Package parts list ( all the stuff to be include in package )
- // These parts can be 'inpk', 'infa', 'inra', 'inr#', 'inrm',
- // 'inff', 'infm', 'inaa', 'inat', 'inat', or 'inbb'
-
- 'infa', 1070; // file atom
- // 7.0 Key Caps Desk Acessory
- },
- }
- };
-
- // 6.0 or greater
- resource 'inpk' ( k60Package ) {
- format0 {
- showsOnCustom, // if this was a subpackage,
- // it would be listed in Custom Install
-
- removable, // include this package or subpackage
- // as a removeable item
-
- dontForceRestart, // don't make user reboot after installation
- k70Package, // 'inpc' resource ID ( item defined below )
- 0, // Package size ( if 0, filled in by ScriptCheck )
-
- "KeyCaps DA in System File", // Custom Install selection text
-
-
- { // Package parts list ( all the stuff to be include in package )
- // These parts can be 'inpk', 'infa', 'inra', 'inr#', 'inrm',
- // 'inff', 'infm', 'inaa', 'inat', 'inat', or 'inbb'
-
- 'inra', 1060; // resource atom
- // 6.0 Key Caps Desk Acessory
- },
- }
- };
-
-
-
- // • package comments
-
- // NOTE: The values that are assigned to the Custom Package Information
- // resource fields do not actually have any affect on the installation and
- // are ignored during installation. They can however assist the user in
- // choosing which packages they would like to include in their Custom
- // Installation or Custom Removal.
-
- // The following included file contains the icons for the two package comments.
- // I created the file with the icon resources ( 'ICN#', 'icl4' and 'icl8' )
- // by opening the application to be installed within ResEdit. I then copied
- // the 'ICN#', 'icl4' and 'icl8' icon resources into a new ResEdit file called
- // "Icons.rsrc" and assigned the resource items an ID of 9128, since their
- // original resource ID's had a value that was illegal for use with 'inpc'
- // resources ( they must be over 1024 ).
- //
- // - An alternative to this method is to derez the application and to paste
- // the resulting resource definitions into this script file and to let the Rez
- // command build the icons every time that the installer script is Rezzed.
- // If you happen to forget to include the resources for the icons, ScriptCheck
- // will complain, but you will still be able to use the Rezzed installer script
- // to successfully perform an installation.
-
- include "Icons.rsrc";
-
- resource 'inpc' ( k70Package ) {
- format1 {
- kCurrentReleaseDate, // Date
- kCurrentVersion, // Version
-
- 20 * 1024, // RAM requirement for this package.
- // This number is in bytes. To generate value of
- // 1 meg in the dialog use ( 1000 * 1024 )
-
- 9128, // Icon rsrc ID ( 'ICON', 'ICN#', 'icl4', 'icl8' )
- // - ID must be greater than 1024
- // - resource item in rezzed script file
-
- k70Package, // 'TEXT' resource ID of item
- // containing package description
- }
- };
-
- resource 'inpc' ( k60Package ) {
- format1 {
- kCurrentReleaseDate, // Date
- kCurrentVersion, // Version
-
- 20 * 1024, // RAM requirement for this package.
- // This number is in bytes. To generate value of
- // 1 meg in the dialog use ( 1000 * 1024 )
-
- 9128, // Icon rsrc ID ( 'ICON', 'ICN#', 'icl4', 'icl8' )
- // - ID must be greater than 1024
- // - resource item in rezzed script file
-
- k60Package, // 'TEXT' resource ID of item
- // containing package description
- }
- };
-
-
- // The following resource items can easily be created manually by creating 'TEXT'
- // resource items in a file and including that file in this script.
- // USE: include "fileWithTextItem.rsrc";
- // NOTE : resource includes use "include" instead of "#include"
- // and are terminated with a semicolon.
-
- data 'TEXT' ( k70Package ) {
- "This is some sample text that would describe what the 7.0 compatible "
- "package contains."
- };
-
- data 'TEXT' ( k60Package ) {
- "This is some sample text that would describe what the 6.0 compatible "
- "package contains."
- };
-
-
- // • file atoms
-
- // file atom for the actual DA file to be installed for System 7
- resource 'infa' (1070) {
- format1 {
- deleteWhenRemoving, // Delete on deinstall
- deleteWhenInstalling, // Remove preexisting
- copy, // Copy on Install
-
- dontIgnoreLockedFile, // Respect file locking
- dontSetFileLocked, // Don't lock file after installation
- useSrcCrDateToCompare, // Use date instead of version
- srcNeedNotExist, // Install if new file
- rsrcForkInRsrcFork, // Rrsc info stored in rsrc fork
- leaveAloneIfNewer, // Don't update a newer file
- updateExisting, // Update if file already exists
- copyIfNewOrUpdate, // Create new or update existing
- rsrcFork, // Copy rsrc info
- dataFork, // Copy data info
- 0, // Size ( filled in by ScriptCheck )
-
- 0x0, // Finder attribute flags
- // ( filled in by ScriptCheck )
-
- kKeyCaps70FileTarget, // target spec for DA file
- {
- kKeyCapsSourceSpec, // Source spec for DA file
- 0, // Data fork size ( filled in by ScriptCheck )
- 0 // Rsrc fork size ( filled in by ScriptCheck )
- },
-
- 0, // The source version number in BCD format
- // ( if this value is zero, tgt file will
- // always be assumed to be older )
-
- 0, // Version compare procedure ( 0 : none )
-
- 0, // Atom extender resource ID ( 0 : none )
-
- "" // Atom description
- // ( if none installer will use filename )
- }
- };
-
- // • resource atoms
-
- // resource atom for the DA rsrc item to be installed for System 6
- resource 'inra' (1060) {
- format1 {
- deleteWhenRemoving, // Delete on deinstall
- dontDeleteWhenInstalling, // Do not remove preexisting
- copy, // Copy on Install
-
- leaveAloneIfNewer, // Do not update a newer file
- tgtRequired, // Target file must already exist
- updateExisting, // Update an existing file
- copyIfNewOrUpdate, // Copy whether target exists or not
- ignoreProtection, // Don't respect file locking
- srcNeedExist, // Source file must exist
- byName, // Use name instead of rsrc ID
- nameMustMatch, // Ignored when using 'byID'
-
- 0, // TARGET - total resource size after installation
- // ( filled by ScriptCheck if 0 )
-
- kSystemFileTarget, // TARGET - file spec ( 'intf' )
- 'DRVR', // TARGET - resource type
- 0, // TARGET - resource ID ( ignored when using 'byName' )
-
- 0x0, // TARGET - resource attribute flags
- // ( filled in by ScriptCheck if 0x0 )
-
- "\0x00Key Caps", // TARGET - resource name
- // this field must be when installing by ID
- {
- kKeyCapsSourceSpec, // SOURCE - file spec ( 'infs' )
- 'DRVR', // SOURCE - resource type
- 14, // SOURCE - resource ID ( ignored when using 'byName' )
- 0, // SOURCE - resource size ( filled by ScriptCheck if 0 )
- "\0x00Key Caps", // SOURCE - resource name
- },
-
- 0x0, // SOURCE - version number for comparisons
- // 0x0 specifies not to perform version comparison
-
- 0, // 'invc' code resource - version comparison routine
- // ( none used here )
-
- 0, // 'inex' resource definition for atom extender
- // ( none used here )
-
- "Key Caps DA", // resource atom description
- }
- };
-
-
- // • file specs
-
- // target file spec to Apple Menu for Key Caps install to System 7
- resource 'intf' (kKeyCaps70FileTarget) {
- format1 {
- noSearchForFile, // use default search path
-
- TypeCrMustMatch, // If this is set to TypeCrMustMatch
- // then a file with a different type
- // and creator than those specified
- // below will not be replaced.
- // If this is set to TypeCrNeedNotMatch
- // then type and creator of an existing
- // target file are ignored.
-
- // The Type and Creator fields will be used to set the
- // file's Type and Creator when a new file is created.
- 'dfil', // TYPE for new file
- 'keyc', // CREATOR for new file
-
- 0, // finder attribute flags
- // filled by ScriptCheck is value is 0
-
- 1, // creation date for new file
- 1, // modification date for new file
- // NOTE: DATE values are filled
- // by ScriptCheck if the value is 1
-
- 0, // search proc ID ( 'insp' ), none used
-
- "special-amnu:Key Caps" // path to target file
- }
- };
-
- // source file spec for Key Caps for System 7 and for System 6
- resource 'infs' ( kKeyCapsSourceSpec ) {
- 'dfil', // TYPE for file search
- 'keyc', // CREATOR for file search
-
- 0x1, // creation DATE for source file
- // ( value of 1, filled in by ScriptCheck
-
- noSearchForFile, // IGNORED in Installer 4.0.x
- TypeCrMustMatch, // TYPE, CREATOR must match file on install disk
- "Disk 1:Key Caps" // PATH to source file
- };
-
-
-
- // target file spec for checking System version on target
- // and for installing DA resource item to System file for System 6
- resource 'intf' (kSystemFileTarget) {
- format1 {
- noSearchForFile, // use default search path
-
- TypeCrNeedNotMatch, // • because system type is different
- // • under System 6 and 7 need to set
- // • this flag to ignore type and creator
- // • so that this file spec can be used
- // • for both systems !!
-
- // These two fields will be ignored because TypeCrNeedNotMatch
- // and this target spec is only used for referencing the System
- // file. Nothing is actually installed using this target spec.
- // But it woulda looked silly to give these bogus values...
- 'zsys', // TYPE for file
- 'MACS', // CREATOR for file
-
- 0, // finder attribute flags
- 1, // creation date for new file
- 1, // modification date for new file
- 0, // search proc ID ( 'insp' ), none used
-
- "special-macs:System" // path to target file
- }
- };
-